<template>
  <div class="semester">
    <div v-if="semesterData" class="top_img_banner">
      <h2 class="title">{{semesterData.specialtyName}}</h2>
      <p class="subtitle">{{semesterData.kkxqName}}</p>
      <div class="claim">
        <div class="title_name">——   本学期考核要求   ——</div>
        <div class="text_body" :style="{height: (openText ? '0.8rem':'4.5rem')}">
           <div v-html="semesterData.checkRequired" class="bjq_body">{{semesterData.checkRequired}}</div>
        </div>
        <a v-if="openText" href="javascript:;" @click="openText = false"><i class="iconfont icon-down2"></i></a>
        <a v-else href="javascript:;" @click="openText = true"><i class="iconfont icon-arrow-up"></i></a>
      </div>
    </div>
    <van-tabs v-model="active" color="#1F93FD" @click="openTab">
      <van-tab title="课程情况" name="a">
        <div v-if="courseData" class="tab_score_item">
          <h2 class="title">学期成绩统计</h2>
          <div class="tab_kc">
            <div class="tab_item">
              <strong>{{courseData.courseTotal}}</strong>
              <p>课程总数</p>
            </div>
            <div class="tab_item">
              <strong>{{courseData.courseAchieve}}</strong>
              <p>已完成课程</p>
            </div>
          </div>
          <div class="tab_list">
            <div class="tab_item" v-for="item in courseData.courseList" :key="item.recId" @click="goCoureIndex(item.courseId, item.classId, item.courseStatus)">
              <img :src="item.courseCover?item.courseCover:'http://css.tt.gzedu.com/qy_oucnet_com/wx_img/score_1.png'" alt="">
              <div class="item_text_body">
                <h3>{{item.courseName}}</h3>
                <p>{{item.homeworkTotal}}个作业</p>
                <div :class="'label_tag '+ (item.examState!=='2'?'wraning':'')">
                  {{item.courseStatus ==='0'?'未开放':
                  item.courseStatus ==='1'?'预习中':'学习中'}}
                </div>
              </div>
            </div>
          </div>
          <div v-if="courseData.courseTotal === 0" class="no_work">
            <img  src="../../../assets/img/modules/score/no_homework.png" alt="">
            <p>暂无数据</p>
          </div>
        </div>
      </van-tab>
      <van-tab title="形考作业" name="b">
        <div v-if="workData"  class="score_count">
          <h2 class="title">形考作业统计</h2>
          <div class="tab_kc">
            <div class="tab_item">
              <strong>{{workData.homeworkTotal}}</strong>
              <p>全部</p>
            </div>
            <div class="tab_item">
              <strong>{{workData.homeworkUnfinished}}</strong>
              <p>未完成</p>
            </div>
            <div class="tab_item">
              <strong>{{workData.homeworkAchieve}}</strong>
              <p>已完成</p>
            </div>
          </div>
          <div class="exercise_list">
            <div class="exercise_item" v-for="item in workData.homeworkList" :key="item.homeworkId" @click="goHomework(item.classId, item.courseId, item.termcourseId, item.courseName, item.chooseId, item.actName, item.actId, item.taskId, item.actTypeId, item.proOver)">
              <h3><span>习题</span> {{item.courseName}}</h3>
              <p>{{item.actName}}</p>
              <p>分值：{{item.needPoint}}分</p>
              <p class="bottom_text">辅导老师：{{item.tutorshipTeacherName}}</p>
              <img class="_bg" :src="item.tutorshipTeacherPic" alt="">
              <img v-if="item.proOver === 'N'" class="title_img" src="../../../assets/img/modules/score/score_11.png" alt="">
              <img v-if="item.proOver === 'Y'"  class="title_img" src="../../../assets/img/modules/score/score_12.png" alt="">
            </div>
          </div>
          <div v-if="workData.homeworkTotal === 0" class="no_work">
            <img  src="../../../assets/img/modules/score/no_homework.png" alt="">
            <p>暂无数据</p>
          </div>
        </div>
      </van-tab>
      <van-tab title="学习情况" name="c">
        <div v-if="bankData" class="behavior_body">
          <h2 class="title">本学期已累计学习行为</h2>
          <div class="tab_number">
            <div class="tab_item">
              <strong>{{bankData.termStudyBehavior}} <span>次</span></strong>
            </div>
            <div class="tab_item">
              <p>需达标 <span>{{bankData.behaviorRequire}}</span> 次</p>
            </div>
          </div>
          <div class="title_h2">累计行为</div>
          <div class="tab_kc">
            <div class="tab_item">
              <strong>{{bankData.courseStudyBehavior}} <span>次</span></strong>
              <p>课程教学</p>
            </div>
            <div class="tab_item">
              <strong>{{bankData.onlineLessonAchieve}} <span>次</span></strong>
              <p>直播课</p>
            </div>
            <div class="tab_item">
              <strong>{{bankData.homeworkAchieve}} <span>次</span></strong>
              <p>课后作业</p>
            </div>
          </div>
          <div class="title_h2">学霸榜</div>
          <div class="ranking_body">
            <div v-if="bankData.ownRank" class="ranking_user">
              <img src="../../../assets/img/modules/score/score_4.png" alt="">
              <div class="text_body">
                <h5>{{bankData.ownRank.studentName}}<span>{{bankData.ownRank.specialtyName}}</span></h5>
                <p>您当前排名第 <span>{{bankData.ownRank.rankNum}}</span> 位</p>
              </div>
              <div class="right_number">{{bankData.ownRank.behaviorTimes}}</div>
            </div>
            <div class="ranking_item"  v-for="(item, index) in bankData.rankList" :key="item.studentId">
              <div class="number" :data-number="index+1">{{index > 2 ? index+1: ''}}</div>
              <div class="user_data">
                <img :src="item.userPic?item.userPic:'http://css.tt.gzedu.com/qy_oucnet_com/wx_img/qxym_xq_8.png'" alt="">
                <div class="text_body">
                  <h5>{{item.studentName}}</h5>
                  <p>{{item.specialtyName}}</p>
                </div>
              </div>
              <div class="right_number">{{item.behaviorTimes}}</div>
            </div>
<!--            <div class="bootom_line">—— 我也是有底线的哦 ——</div>-->
          </div>
          <div v-if="bankData.rankList.length === 0" class="no_work">
            <img  src="../../../assets/img/modules/score/no_homework.png" alt="">
            <p>暂无数据</p>
          </div>
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>
<script>
export default {
  name: 'semester',
  components: {},
  data () {
    return {
      openText: true,
      active: 'a',
      semesterData: null,
      studentId: 0, // 学生Id
      gradeId: 0, // 班级ID
      courseId: 0, // 课程ID
      kbDate: 20190523, // 作业安排日期
      courseData: [], // 课程
      workData: [], // 作业
      bankData: {
        rankList: []
      } // 学习情况
    }
  },
  props: {},
  watch: {},
  methods: {
    goCoureIndex (courseId, classId, index) {
      if (index !== '0') {
        // eslint-disable-next-line no-undef
        Phone.goCourseIndex(courseId, classId)
      }
    },
    goHomework (classId, courseId, termCourseId, courseName, chooseId, actName, actId, taskId, actTypeId, proOver) {
      // eslint-disable-next-line no-undef
      Phone.goHomework(classId, courseId, termCourseId, courseName, chooseId, actName, actId, taskId, actTypeId, proOver)
    },
    /*
     *@author wf_Huang
     *@Time 2019/8/9 0009 16:26
     *@function  切换
     *****************************************/
    openTab (value) {
      if (value === 'a') {
        this.getCourse()
      }
      if (value === 'b') {
        this.getWork()
      }
      if (value === 'c') {
        this.getRank()
      }
    },
    /*
     *@author wf_Huang
     *@Time 2019/8/8 0008 10:22
     *@function  获取课程情况
     *****************************************/
    getCourse () {
      this.$http({
        url: `${window.SITE_CONFIG['personalListURL']}/api/courseNew/termCourseList?studentId=${this.$store.state.score.studentId}&gradeId=${this.$store.state.score.gradeId}`,
        method: 'get',
        withCredentials: false
      }).then(({ data: res }) => {
        if (res.msgCode !== 200) {
          this.$toast('请求失败，请重试')
          return false
        }
        this.courseData = res.data
      }).catch(() => {})
    },
    /*
     *@author wf_Huang
     *@Time 2019/8/8 0008 10:22
     *@function  获取形考作业
     *****************************************/
    getWork () {
      this.$http({
        url: `${window.SITE_CONFIG['personalListURL']}/api/courseNew/homeworkList?studentId=${this.$store.state.score.studentId}&gradeId=&courseId=&kbDate=`,
        method: 'get',
        withCredentials: false
      }).then(({ data: res }) => {
        if (res.msgCode !== 200) {
          this.$toast('请求失败，请重试')
          return false
        }
        this.workData = res.data
      }).catch(() => {})
    },
    /*
     *@author wf_Huang
     *@Time 2019/8/8 0008 10:22
     *@function  获取p学习情况
     *****************************************/
    getRank () {
      this.$http({
        url: `${window.SITE_CONFIG['personalListURL']}/api/courseNew/studyBehaviorRank?studentId=${this.$store.state.score.studentId}&gradeId=${this.$store.state.score.gradeId}&limitSize=10`,
        method: 'get',
        withCredentials: false
      }).then(({ data: res }) => {
        if (res.msgCode !== 200) {
          this.$toast('请求失败，请重试')
          return false
        }
        this.bankData = res.data
      }).catch(() => {})
    },
    /*
     *@author wf_Huang
     *@Time 2019/8/8 0008 10:22
     *@function  获取学习统计信息
     *****************************************/
    getData () {
      this.$http({
        url: `${window.SITE_CONFIG['personalListURL']}/api/courseNew/specialtyStudyStatis?gradeId=${this.$store.state.score.gradeId}&studentId=${this.$store.state.score.studentId}`,
        method: 'get',
        withCredentials: false
      }).then(({ data: res }) => {
        if (res.msgCode !== 200) {
          this.$toast('请求失败，请重试')
          return false
        }
        this.semesterData = res.data
      }).catch(() => {})
    }
  },
  computed: {},
  created () {
  },
  mounted () {
    if (this.$route.query.studentId) {
      this.$store.state.score.studentId = this.$route.query.studentId
      localStorage.setItem('stateData', JSON.stringify(this.$store.state))
    }
    if (this.$route.query.gradeId) {
      this.$store.state.score.gradeId = this.$route.query.gradeId
      localStorage.setItem('stateData', JSON.stringify(this.$store.state))
    }
    if (this.$route.query.active) {
      this.$store.state.score.active = this.$route.query.active
      localStorage.setItem('stateData', JSON.stringify(this.$store.state))
    }
    this.active = this.$store.state.score.active
    this.openTab(this.active)
    this.getCourse()
    this.getData()
  },
  destroyed () {
  }
}
</script>

<style lang="scss" scoped>
  .van-tab {
    border-bottom: 6px solid #efefef !important;
  }
  .semester {
    .top_img_banner{
      padding: 50px 32px 80px;
      .title{
        font-size: 36px;
        color: #4A4A4A;
        letter-spacing: 0;
        text-align: center;
        margin: 15px 0;
      }
      .subtitle{
        font-size: 28px;
        color: #666666;
        letter-spacing: 0;
        text-align: center;
        margin: 15px 0 50px;
      }
      .claim{
        background-color: #F6FAFF;
        box-shadow: 0 2px 15px 0 rgba(0,0,0,0.10);
        padding: 30px;
        position: relative;
        .title_name{
          font-size: 28px;
          color: #1F93FD;
          letter-spacing: 0;
          text-align: center;
          margin-bottom: 30px;
        }
        .text_body{
          font-size: 26px;
          color: #666666;
          line-height: 37px;
          -webkit-transition: all 0.6s;
          -moz-transition: all 0.6s;
          -ms-transition: all 0.6s;
          -o-transition: all 0.6s;
          transition: all 0.6s;
          height: 80px;
          overflow: hidden;
          .warning{
            color: #FBA146;
          }
          .bjq_body{
            margin: 0 -30px;
            padding: 0 40px;
          }
        }
        a{
          position: absolute;
          width: 150px;
          height: 60px;
          bottom: -60px;
          left: 50%;
          text-align: center;
          transform: translate(-50%, -50%);
          border-radius: 100%;
          background-color: #F6FAFF;
          box-shadow: 0 8px 10px 0 rgba(0,0,0,0.06);
          line-height: 30px;
          -webkit-transition: all 0.6s;
          -moz-transition: all 0.6s;
          -ms-transition: all 0.6s;
          -o-transition: all 0.6s;
          transition: all 0.6s;
          i{
            font-size: 30px;
            color: #666666;
            font-weight: bold;
          }
        }
      }
    }
    .tab_score_item{
      margin: 32px 32px 80px 32px;
      padding-bottom: 60px;
      /*border-bottom: 3px dashed #efefef;*/
      .title{
        font-size: 36px;
        color: #4A4A4A;
        letter-spacing: 0;
        text-align: center;
        font-family: PingFangSC-Semibold;
        margin: 45px 0;
        text-align: center;
      }
      .tab_kc{
        display: flex;
        align-content: center;
        margin: 60px 0;
        .tab_item{
          flex: 1;
          text-align: center;
          &:nth-child(1){
            border-right: 1px solid #efefef;
          }
          strong{
            font-size: 52px;
            color: #1F93FD;
            letter-spacing: 0;
            display: block;
          }
          p{
            font-size: 22px;
            color: #666666;
            letter-spacing: 0;
            margin: 0;
          }
        }
      }
      .tab_list{
        .tab_item{
          background: #FFFFFF;
          box-shadow: 0 2px 8px 0 rgba(0,0,0,0.10);
          border-radius: 8px;
          margin-top: 30px;
          padding: 20px;
          position: relative;
          height: 176px;
          img{
            width: 132px;
            height: 132px;
            position: absolute;
          }
          .item_text_body{
            padding: 20px 20px 20px 150px;
            position: relative;
            overflow: hidden;
            border-radius: 8px;
            margin: -20px -20px -20px 0;
            h3{
              font-family: PingFangSC-Medium;
              font-size: 32px;
              color: #222222;
              letter-spacing: 0;
              line-height: 32px;
              margin: 25px 0;
              display: -webkit-box;
              -webkit-box-orient: vertical;
              -webkit-line-clamp: 1;
              overflow:hidden;
            }
            p{
              font-family: PingFangSC-Regular;
              font-size: 24px;
              color: #666666;
              letter-spacing: 0;
              line-height: 24px;
              margin: 20px 0;
            }
            .label_tag{
              background: #027FFE;
              transform: rotate(45deg);
              font-family: PingFangSC-Regular;
              font-size: 24px;
              color: #FFFFFF;
              letter-spacing: 0;
              text-align: center;
              line-height: 28px;
              width: 150px;
              height: 150px;
              padding: 10px;
              display: flex;
              align-items: flex-end;
              justify-content: center;
              position: absolute;
              right: -75px;
              top: -75px;
            }
            .wraning{
              background: #FBA146;
            }
          }
        }
      }
    }
    .score_count{
      margin: 32px 32px 80px 32px;
      padding-bottom: 60px;
      /*border-bottom: 3px dashed #efefef;*/
      .title{
        font-size: 36px;
        color: #4A4A4A;
        letter-spacing: 0;
        text-align: center;
        font-family: PingFangSC-Semibold;
        margin: 45px 0;
        text-align: center;
      }
      .tab_kc{
        display: flex;
        align-content: center;
        margin: 60px 0;
        .tab_item{
          flex: 1;
          text-align: center;
          strong{
            font-size: 52px;
            color: #1F93FD;
            letter-spacing: 0;
            display: block;
          }
          p{
            font-size: 22px;
            color: #666666;
            letter-spacing: 0;
            margin: 0;
          }
        }
      }
      .exercise_list{
        .exercise_item{
          background: #FFFFFF;
          box-shadow: 0 2px 10px 0 rgba(0,0,0,0.10);
          border-radius: 4px;
          height: 244px;
          position: relative;
          padding: 20px;
          margin-top: 30px;
          h3{
            font-family: PingFangSC-Medium;
            font-size: 30px;
            color: #000000;
            text-align: left;
            line-height: 30px;
            margin:20px 0 30px;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            overflow:hidden;
            span{
              width: 60px;
              line-height: 34px;
              text-align: center;
              border: 1px solid #1F93FD;
              color: #1F93FD;
              border-radius: 3px;
              font-size: 22px;
              font-weight: normal;
              display: inline-block;
            }
          }
          p{
            font-family: PingFangSC-Regular;
            font-size: 22px;
            color: #999999;
            text-align: left;
            margin: 10px 0;
          }
          .bottom_text{
            font-family: PingFangSC-Regular;
            font-size: 24px;
            color: #6E6E6E;
            margin: 10px 0;
            margin: 30px 0 0;
          }
          ._bg{
            width: 110px;
            height: 110px;
            border-radius: 50%;
            position: absolute;
            top: 50%;
            right: 0px;
            transform: translate(-50%, -50%);
          }
          .title_img{
            width: 117px;
            height: 36px;
            position: absolute;
            top: -8px;
            right: 40px;
          }
        }
      }
    }
    .behavior_body{
      margin: 32px 32px 80px 32px;
      padding-bottom: 60px;
      .title{
        font-size: 36px;
        color: #4A4A4A;
        letter-spacing: 0;
        text-align: center;
        font-family: PingFangSC-Semibold;
        margin: 45px 0;
        text-align: center;
      }
      .tab_number{
        display: flex;
        align-content: center;
        margin: 60px 30px;
        .tab_item{
          flex: 1;
          text-align: center;
          strong{
            font-family: DINAlternate-Bold;
            font-size: 100px;
            color: #1F93FD;
            letter-spacing: 0;
            display: block;
            text-align: left;
            span{
              font-family: PingFangSC-Regular;
              font-size: 30px;
              color: #666666;
              letter-spacing: 0;
              line-height: 24px;
              font-weight: normal;
            }
          }
          p{
            font-family: PingFangSC-Regular;
            font-size: 30px;
            color: #666666;
            letter-spacing: 0;
            text-align: right;
            span{
              font-family: PingFangSC-Regular;
              font-size: 32px;
              color: #FBA34A;
              letter-spacing: 0;
              line-height: 42px;
            }
          }
        }
      }
      .title_h2{
        font-family: PingFangSC-Regular;
        font-size: 28px;
        color: #222222;
        letter-spacing: 0;
        border-left: 7px solid #1F93FD;
        padding-left: 15px;
      }
      .tab_kc{
        display: flex;
        align-content: center;
        margin: 60px 0;
        .tab_item{
          flex: 1;
          text-align: center;
          strong{
            font-size: 52px;
            color: #1F93FD;
            letter-spacing: 0;
            display: block;
            span{
              font-size: 22px;
              color: #666666;
              letter-spacing: 0;
              font-weight: normal;
            }
          }
          p{
            font-size: 22px;
            color: #666666;
            letter-spacing: 0;
            margin: 0;
          }
        }
      }
      .ranking_body{
        .ranking_user{
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 50px 0;
          img{
            width: 110px;
            height: 110px;
            border-radius: 100px;
          }
          .text_body{
            width: 68%;
            h5{
              font-family: PingFangSC-Medium;
              font-size: 36px;
              color: #333333;
              letter-spacing: 0;
              line-height: 28px;
              margin: 0;
              span{
                font-size: 24px;
                color: #6B6B6B;
                letter-spacing: 0;
                line-height: 28px;
                font-weight: normal;
              }
            }
            p{
              font-size: 28px;
              color: #333333;
              letter-spacing: 0;
              line-height: 28px;
              margin: 10px 0;
              span{
                color: #1F93FD;
              }
            }
          }
          .right_number{
            font-family: PingFangSC-Regular;
            font-size: 30px;
            color: #4A4A4A;
            letter-spacing: 0;
            text-align: right;
            line-height: 28px;
          }
        }
        .ranking_item{
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 35px 0;
          .number{
            width: 68px;
            height: 49px;
            font-size: 28px;
            color: #333333;
            display: flex;
            align-items: center;
            justify-content: center;
          }
          .number[data-number='1']{
            background: url("../../../assets/img/modules/score/score_6.png") no-repeat center;
            background-size: 100%;
          }
          .number[data-number='2']{
            background: url("../../../assets/img/modules/score/score_7.png") no-repeat center;
            background-size: 100%;
          }
          .number[data-number='3']{
            background: url("../../../assets/img/modules/score/score_8.png") no-repeat center;
            background-size: 100%;
          }
          .user_data{
            display: flex;
            width: 70%;
            justify-content: space-between;
            img{
              width: 90px;
              height: 90px;
              border-radius: 100px;
            }
            .text_body{
              width: 75%;
              h5{
                font-size: 28px;
                color: #333333;
                letter-spacing: 0;
                margin: 10px 0;
              }
              p{
                font-size: 24px;
                color: #9B9B9B;
                letter-spacing: 0;
                margin: 0;
              }
            }
          }
          .right_number{
            font-family: PingFangSC-Regular;
            font-size: 30px;
            color: #4A4A4A;
            letter-spacing: 0;
            text-align: right;
            line-height: 28px;
          }
        }
        .bootom_line{
          ont-family: PingFangSC-Regular;
          font-size: 26px;
          text-align: center;
          color: #C8C8C8;
        }
      }
    }
    .no_work{
      padding: 50px;
      text-align: center;
      img{
        display: block;
        margin: 0 auto;
        width: 400px;
      }
      p{
        font-size: 24px;
        color: #999999;
      }
    }
  }
</style>
